package com.ruoyi.project.para.paeaParaTxnCde.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.para.paeaParaTxnCde.domain.PaeaParaTxnCde;
import com.ruoyi.project.para.paeaParaTxnCde.service.IPaeaParaTxnCdeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 交易码查询Controller
 *
 * @author gang.wei
 * @date 2020-03-27
 */
@Controller
@RequestMapping("/para/paeaParaTxnCde")
public class PaeaParaTxnCdeController extends BaseController
{
    private String prefix = "para/paeaParaTxnCde";

    @Autowired
    private IPaeaParaTxnCdeService paeaParaTxnCdeService;

    @RequiresPermissions("para:paeaParaTxnCde:view")
    @GetMapping()
    public String paeaParaTxnCde()
    {
        return prefix + "/paeaParaTxnCde";
    }

    /**
     * 查询交易码查询列表
     */
    @RequiresPermissions("para:paeaParaTxnCde:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaParaTxnCde paeaParaTxnCde)
    {
        startPage();
        List<PaeaParaTxnCde> list = paeaParaTxnCdeService.list(new QueryWrapper<>(paeaParaTxnCde));
        return getDataTable(list);
    }

    /**
     * 导出交易码查询列表
     */
    @RequiresPermissions("para:paeaParaTxnCde:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaParaTxnCde paeaParaTxnCde)
    {
        List<PaeaParaTxnCde> list = paeaParaTxnCdeService.list(new QueryWrapper<>(paeaParaTxnCde));
        ExcelUtil<PaeaParaTxnCde> util = new ExcelUtil<PaeaParaTxnCde>(PaeaParaTxnCde.class);
        return util.exportExcel(list, "paeaParaTxnCde");
    }

    /**
     * 新增交易码查询
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交易码查询
     */
    @RequiresPermissions("para:paeaParaTxnCde:add")
    @Log(title = "交易码查询", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaParaTxnCde paeaParaTxnCde)
    {
        paeaParaTxnCde.setId(paeaParaTxnCde.getCode());
        return toAjax(paeaParaTxnCdeService.saveOrUpdate(paeaParaTxnCde));
    }

    /**
     * 修改交易码查询
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaParaTxnCde paeaParaTxnCde = paeaParaTxnCdeService.getById(id);
        mmap.put("paeaParaTxnCde", paeaParaTxnCde);
        return prefix + "/edit";
    }

    /**
     * 修改保存交易码查询
     */
    @RequiresPermissions("para:paeaParaTxnCde:edit")
    @Log(title = "交易码查询", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaParaTxnCde paeaParaTxnCde)
    {
        return toAjax(paeaParaTxnCdeService.saveOrUpdate(paeaParaTxnCde));
    }

    /**
     * 删除交易码查询
     */
    @RequiresPermissions("para:paeaParaTxnCde:remove")
    @Log(title = "交易码查询", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaParaTxnCdeService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
